using UnityEngine;

public class WaitPositionWithTimeout : WaitInstruction {
	public Vector3 Position;
	public float PositionMargin = 2f;
	public double TimeoutTime;

	public WaitPositionWithTimeout(ShipProgram program, Vector3 position, float timeOutSeconds = 99999999f, float positionMargin = 2f) : base(program) {
		Position= position;
		PositionMargin = positionMargin;
		TimeoutTime = program.Global.Time + timeOutSeconds;
	}

	public override bool Check() {
		return Vector3.Distance(Position, _program.Ship.ShipPosition) < PositionMargin  || _program.Global.Time > TimeoutTime;
	}
}
